/**
 * createTime: 2018/3/20 11:39
 * author: zhibin.zhao
 * description:
 */
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
/*app.param('id', function (req, res, next, id) {
    console.log('只会调用一次');
    next();
});

app.get('/user/:id', function (req, res, next) {
    console.log('这里会被匹配到');
    next();
});

app.get('/user/:id', function (req, res) {
    console.log('这里也会被匹配到');
    res.end();
});*/

var express = require('express');

var app = express(); // the main app

app.engine('html', require('ejs').renderFile);

app.set('views', './views');  // 指定模板文件存放位置
app.set('view engine', 'html')  // 设置默认的模板引擎
app.use(bodyParser());
app.get('/test/:name/:age', function (req, res) {
    res.send('name = '+req.params.name+', age = '+ req.params.age);
});

app.get('/test', function (req, res) {
    res.send(req.query);
})
app.get('/', function (req, res) {
    // res.render('index');
    res.send();
})
app.post('/', function (req, res) {
    res.send(req.body);
})

app.listen(3000);